package com.allen.app.common.utils;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;

/**
 * @author Leon (234239150@qq.com) created in 17:55 18.8.4
 */
public class MapProxy<K, V> {

    private volatile Map<K, V> delegate;

    public MapProxy() {
        this.delegate = new HashMap<>();
    }

    public MapProxy(int initialCapacity) {
        this.delegate = new HashMap<>(initialCapacity);
    }

    public MapProxy(int initialCapacity, float loadFactor) {
        this.delegate = new HashMap<>(initialCapacity, loadFactor);
    }

    public MapProxy(Map<? extends K, ? extends V> m) {
        this.delegate = new HashMap<>(m);
    }

    public int size() {
        return this.delegate.size();
    }


    public boolean isEmpty() {
        return this.delegate.isEmpty();
    }


    public boolean containsKey(Object key) {
        return this.delegate.containsKey(key);
    }


    public boolean containsValue(Object value) {
        return this.delegate.containsValue(value);
    }


    public V get(Object key) {
        return this.delegate.get(key);
    }


    public V put(K key, V value) {
        return this.delegate.put(key, value);
    }


    public V remove(Object key) {
        return this.delegate.remove(key);
    }


    public void putAll(Map<? extends K, ? extends V> m) {
        this.delegate.putAll(m);
    }


    public void clear() {
        this.delegate.clear();
    }


    public Set<K> keySet() {
        return this.delegate.keySet();
    }


    public Collection<V> values() {
        return this.delegate.values();
    }


    public Set<Map.Entry<K, V>> entrySet() {
        return this.delegate.entrySet();
    }


    public V getOrDefault(Object key, V defaultValue) {
        return this.delegate.getOrDefault(key, defaultValue);
    }


    public void forEach(BiConsumer<? super K, ? super V> action) {
        this.delegate.forEach(action);
    }


    public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
        this.delegate.replaceAll(function);
    }


    public V putIfAbsent(K key, V value) {
        return this.delegate.putIfAbsent(key, value);
    }

    public boolean remove(Object key, Object value) {
        return this.delegate.remove(key, value);
    }


    public boolean replace(K key, V oldValue, V newValue) {
        return this.delegate.replace(key, oldValue, newValue);
    }


    public V replace(K key, V value) {
        return this.delegate.replace(key, value);
    }


    public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
        return this.delegate.computeIfAbsent(key, mappingFunction);
    }


    public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
        return this.delegate.computeIfPresent(key, remappingFunction);
    }


    public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
        return this.delegate.compute(key, remappingFunction);
    }


    public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
        return this.delegate.merge(key, value, remappingFunction);
    }
}
